package com.e2oto.seller.modules.seller.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.e2oto.seller.R;
import com.e2oto.seller.modules.seller.bean.SecondSystemCategoryBean;
import com.e2oto.seller.modules.seller.bean.SellerAddCategoryBean;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;

import java.util.List;

/**
 * Created by ZhangLiQiang on 2017/11/24.
 */

public class SellerAddCategoryTagAdapter extends TagAdapter<SellerAddCategoryBean> {

    private Context mContext;
    private List<SellerAddCategoryBean> data;

    public SellerAddCategoryTagAdapter(List<SellerAddCategoryBean> data, Context mContext) {
        super(data);
        this.mContext = mContext;
        this.data=data;
    }


    @Override
    public View getView(FlowLayout parent, int position, SellerAddCategoryBean bean) {
        View view = View.inflate(mContext, R.layout.item_common_category_tag, null);
        TextView tv = (TextView) view.findViewById(R.id.item_category_tv);
        tv.setText(bean.getName());
        return view;
    }
    @Override
    public void onSelected(int position, View view) {
        super.onSelected(position, view);
        if (!view.isSelected()) {
            view.setSelected(true);
        }
    }

    @Override
    public void unSelected(int position, View view) {
        super.unSelected(position, view);
        if (view.isSelected()) {
            view.setSelected(false);
        }

    }

    public List<SellerAddCategoryBean>  getDataList(){
        return data;
    }
}
